<!DOCTYPE html>
<html>
<#include "../../common/header.ftl">
<script src="${basePath}/js/order/list.js?v=201711021700"></script>

<head>
<meta charset="UTF-8">
<title>订单管理</title>
<style>
	.left{
		float:left;
		min-width:100px;
		margin-left: 10px;
	}
	.table-margin{
		margin:5px 3%;
		width:92%;
	}
	.red-text{
		color:red;
	}
</style>

</head>
<body>
   
<div class="container" style="margin-left:5%;width:90%">
	<form class="layui-form left" action="#" >
		<div class="layui-form-item ">
			<label class="layui-form-label left">订单状态</label>
		    <div class="layui-input-block left">
		      <select name="status" >
		        <option value="">所有</option>
		        <option value="">所有</option>
		        <option value="00" <#if param.status?? && param.status=='00'>selected </#if>>待付款</option>
		        <option value="10" <#if param.status?? && param.status=='10'>selected </#if>>待发货</option>
		        <option value="20" <#if param.status?? && param.status=='20'>selected </#if>>待收货</option>
		        <option value="30" <#if param.status?? && param.status=='30'>selected </#if>>待评价</option>
		        <option value="40" <#if param.status?? && param.status=='40'>selected </#if>>已完成</option>
		        <option value="91" <#if param.status?? && param.status=='91'>selected </#if>>已取消</option>
		        <option value="99" <#if param.status?? && param.status=='99'>selected </#if>>异常</option>
		      </select>
		    </div>
		    <label class="layui-form-label left">创建时间</label>
		    <div class="layui-input-inline left">
		      <input class="layui-input" placeholder="开始" readonly id="LAY_demorange_s"  name="startTime" value="${param.startTime!}">
		    </div>
		    <div class="layui-form-mid">-</div>
		    <div class="layui-input-inline left">
		      <input class="layui-input " placeholder="截止" readonly id="LAY_demorange_e"  name="endTime" value="${param.endTime!}">
		    </div>
		</div>
		<div class="layui-form-item ">
			<label class="layui-form-label left">商品数量</label>
		    <div class="layui-input-inline left">
		      <input class="layui-input" placeholder="最小值"   name="goodsNumMin" value="${param.goodsNumMin!}">
		    </div>
		    <div class="layui-form-mid">-</div>
		    <div class="layui-input-inline left">
		      <input class="layui-input " placeholder="最大值"  name="goodsNumMax" value="${param.goodsNumMax!}">
		    </div>
		    
		    <label class="layui-form-label left">支付金额</label>
		    <div class="layui-input-inline left">
		      <input class="layui-input" placeholder="最小值" name="payJeMin" value="${param.payJeMin!}">
		    </div>
		    <div class="layui-form-mid">-</div>
		    <div class="layui-input-inline left">
		      <input class="layui-input " placeholder="最大值" name="payJeMax" value="${param.payJeMax!}">
		    </div>
		</div>
		<div class="layui-form-item ">
		    <div class="layui-input-block left">
		      <input type="text" name="keyword" value="${param.keyword!}"   placeholder="昵称/手机号/订单编号"  
		      class="layui-input" style="width:400px;margin-right:200px;margin-left:30px">
		    </div>
		     <div class="layui-input-block left">
		      <button type="button" class="layui-btn"  id="search-button">搜索</button>
		    </div>
		</div>
	</form>
</div>
<table class="table table-margin">
  <thead>
      <tr>
         <th>编号</th>
         <th>用户账号</th>
         <th>用户余额</th>
         <th>订单金额</th>
         <th>订单折扣</th>
         <th>折扣金额</th>
         <th>总金额</th>
         <th>商品数</th>
         <th>付款金额</th>
         <th>退款金额</th>
         <th>订单状态</th>
         <th>创建时间</th>
         <th>付款时间</th>
         <th>备注</th>
         <th>操作</th>
      </tr>
  </thead>
  <tbody>
	<#list page.itemList! as order>
		<tr>
			<td ><a href="javascript:void(0);" onclick="showOrderDetail('${order.id!}')">${order.orderNo!}</a></td>
			<td>${order.mobileNo!}</td>
			<td>${order.userMoney?string('#0.00')}</td>
			<td>${order.orderJe?string('#0.00')}</td>
			<td>${order.discount!}</td>
			<td>${order.discountJe?string('#0.00')}</td>
			<td>${order.totalJe?string('#0.00')}</td>
			<td>${order.goodsNum!}</td>
			<td>${order.payJe?string('#0.00')}</td>
			<td>${order.refundJe?string('#0.00')}</td>
			<td><#if order.status?? && order.status=="00">
					<span class="red-text">${order.statusName!}</span>
				<#else>
					${order.statusName!}
				</#if>
			</td>
			<td>${order.createTime!}</td>
			<td>${order.payTime!}</td>
			<td>${order.remark!}</td>
			<td>
				<div class="btn-group">
				  <button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				    	操作<span class="caret"></span>
				  </button>
				  <ul class="dropdown-menu">
				  <#if order.status == '00'>
					  <#if permission?? && (permission.P804??)>
					  	<li><a href="javascript:void(0);" onclick="payOrder('${order.id}','${order.userMoney!0}','${order.totalJe!0}')">支付订单</a></li>
					  </#if>
					  <#if permission?? && (permission.P807??)>
				  		<li><a href="javascript:void(0);" onclick="updateStatus('${order.id}','91')">取消订单</a></li>
					  </#if>
				  <#elseif order.status == '10'>
				  		<#if permission?? && (permission.P805??)>
				    		<li><a href="javascript:void(0);" onclick="sendGoods('${order.id}')">发货</a></li>
				  		</#if>
				  </#if>
				  <#if order.status == '10' || order.status == '20' || order.status == '30' || order.status == '40'>
				  	 <#if permission?? && (permission.P806??)>
				  		<li><a href="javascript:void(0);" onclick="refundOrder('${order.id}')">申请退货</a></li>
				  	 </#if>
				  </#if>
				  <#if permission?? && (permission.P807??)>
				  	<li><a href="javascript:void(0);" onclick="updateStatus('${order.id}','99')">转异常单</a></li>
				  </#if>
				  </ul>
				</div>
			</td>
		</tr>
	</#list>
  </tbody>
</table>
	<#-- 翻页模块代码 -->
	<ul class="pager">
		<li><a href="javascript:void(0);" onclick="fanye('1')">首页</a></li>
		<#if (page.pageNo>1) > 
		<li><a	href="javascript:void(0);" onclick="fanye('${page.prevPage}')">上一页</a></li>
		<#else>
		<li><a href="javascript:void(0);">上一页</a></li> 
		</#if>
		<li><a href="javascript:void(0);">第${page.pageNo}页/共${page.totalPage}页</a></li>
		<#if (page.nextPage>page.pageNo) >
		<li><a href="javascript:void(0);" onclick="fanye('${page.nextPage}')">下一页</a></li>
		<#else>
		<li><a href="javascript:void(0);">下一页</a></li>
		</#if>
		<li><a href="javascript:void(0);" onclick="fanye('${page.totalPage}')">尾页</a></li>
	</ul>
  
</body>
<script type="text/javascript">
	var basePath="${basePath}";
	var init={
	    status:"${param.status!}",
		keyword:"${param.keyword!}",
		startTime:"${param.startTime!}",
		endTime:"${param.endTime!}",
		goodsNumMin:"${param.goodsNumMin!}",
		goodsNumMax:"${param.goodsNumMax!}",
		payJeMin:"${param.payJeMin!}",
		payJeMax:"${param.payJeMax!}"
	}
	$(function(){
		layui.use(['form', 'layer','laydate'] , function(){
		  var layer = layui.layer;
		  var form = layui.form(); 
		  
		  var laydate = layui.laydate;
		  var c_min;
		  var c_max;
		  if(init.startTime){
		  	c_min = init.startTime;
		  }else{
		    c_min = laydate.now();
		  }
		  if(init.endTime){
		   c_max = init.endTime;
		  }else{
		   c_max ='2099-12-29';
		  }
		  var start = {
		    min: '2017-01-01' 
		    ,max: c_max
		    ,istoday: false
		    ,choose: function(datas){
		      end.min = datas; //开始日选好后，重置结束日的最小日期
		      end.start = datas //将结束日的初始值设定为开始日
		    }
		  };
		  var end = {
		    min: c_min
		    ,max: '2099-12-29'
		    ,istoday: false
		    ,choose: function(datas){
		      start.max = datas; //结束日选好后，重置开始日的最大日期
		    }
		  };
		  document.getElementById('LAY_demorange_s').onclick = function(){
		    start.elem = this;
		    laydate(start);
		  }
		  document.getElementById('LAY_demorange_e').onclick = function(){
		    end.elem = this
		    laydate(end);
		  }
		});
	});
</script>
</html>